package com.ruoyi.labour.service.impl;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.labour.domain.LabourAnnouncement;
import com.ruoyi.labour.mapper.AnnouncementMapper;
import com.ruoyi.labour.service.AnnouncementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @ClassName: AnnouncementServiceImpl
 * @Description:
 * @Author: Awen
 * @Date: 2023/5/16 11:41
 */
@Service
public class AnnouncementServiceImpl implements AnnouncementService {

    @Autowired
    private AnnouncementMapper announcementMapper;

    /**
     * 修改公告信息
     *
     * @param msg
     * @return
     */
    @Override
    public R updateAnnouncement(String msg) {
        int i = announcementMapper.checkAnnouncementIsExist();
        if (i > 0) {
            announcementMapper.updateAnnouncement(msg);
            return R.ok("修改成功");
        } else {
            return R.fail("公告信息不存在");
        }

    }

    /**
     * 获取公告信息
     *
     * @return
     */
    @Override
    public R getAnnouncement() {

        LabourAnnouncement announcement = announcementMapper.getAnnouncement();

        return R.ok(announcement);
    }
}
